// 自定义错误
// 发生错误时，捕获错误，然后抛出我们自定义的错误
class ServiceError extends Error{
    /**
     * 
     * @param {*} message 
     * @param {*} code 
     */
    constructor(message, code){
        super(message);
        this.code = code;
    }

    toResponseJSON(){

    }
}


// 文件上传错误
exports.UploadError = class extends ServiceError{
    constructor(message) {
        super(message, 413);
    }
}

new this.UploadError("文件尺寸过大")
// 禁止访问错误
exports.ForbiddenError = class extends ServiceError{
    constructor(message) {
        super(message, 401);
    }
}
// 验证错误
exports.ValidationError = class extends ServiceError{
    constructor(message) {
        super(message, 406);
    }
}

// 无资源错误
exports.NotFoundError = class extends ServiceError{
    constructor() {
        super("not found", 406);
    }
}

// 未知错误
exports.UnknownError = class extends ServiceError{
    constructor() {
        super("server internal error", 500);
    }
}